
import { BuiltInData } from '../../Config/tableOptions'
import { BaseFormButton } from '../../Utils/TableButton'
import { commonTableList } from '../../Config/tableCommon'
import { SelectModal, SelectDateModal, RenderDate } from '../../Template/ProTableOptions'



// TODO 入参 uuid, url, ProTableEvent, ClientData, Permission, actionRef
const Scenes = async ({ url, ProTableEvent, ClientData, actionRef }) => {
    const get = `get${url}`
    const pos = `pos${url}`
    const put = `put${url}`
    const del = `del${url}`

    const initialValues = { isEnabled: 1 }


    const options = () => {
        return ([
            <BaseFormButton
                key='add'
                event='NewAdd'
                ProTableEvent={ProTableEvent}
                type="primary"
                icon="add"
                title="新增"
                data={{ params: { pos, put, initialValues, columns } }}
            />
        ])
    }
    const columns = [
        {
            ...commonTableList.uuid,
            title: '场景ID',
            hideInTable: false,
            width: 320,
            copyable: true
        },
        { ...commonTableList.tableName, width: 200 },
        {
            dataIndex: 'category',
            title: '类型',
            width: 200,
            valueType: 'select',
            rules: true,
            valueEnum: ClientData.dictionary['3722430c-a241-44b6-9bb3-5ed44f6ad635'],
        },
        { ...commonTableList.isEnabled, rules: true },
        { ...commonTableList.sortId, rules: true },
        commonTableList.remark,
        commonTableList.createUserName,
        commonTableList.createTime,
        commonTableList.updateUserName,
        commonTableList.updateTime,
        {
            title: '操作',
            valueType: 'systemOperation',
            fixed: 'right',
            width: 240,
            hideInSearch: true,
            hideInAdded: true,
            hideInModify: true,
            render: (_, record) => {
                const { uuid } = record
                return [
                    <BaseFormButton
                        key='A01'
                        event='Modify'
                        ProTableEvent={ProTableEvent}
                        title="修改"
                        data={{ params: { pos, put, initialValues, columns }, record }}
                    />,
                    <BaseFormButton
                        key='A02'
                        event='MapButton'
                        ProTableEvent={ProTableEvent}
                        title="详情"
                        data={record}
                    />,
                    <BaseFormButton
                        key='delete'
                        event='Delete'
                        ProTableEvent={ProTableEvent}
                        title="删除"
                        danger
                        data={{ url: del, path: [uuid], actionRef }}
                    />,
                ]
            },
        },
    ]



    return {
        get,
        columns,
        hideInSearch: true,
        params: { pageIndex: 1, pageSize: 10 },
        options
    }
}

export default Scenes